<?php

namespace App\Http\Controllers\Pay\Merchant;

use App\Http\Controllers\BaseController;
use App\Http\Middleware\OpenShop\MerchantAppAuth;
use App\Models\OpenShop\InvestmentPromotion\OpenShopSignOrderModel;
use App\Service\OpenShop\Wap\SignOrderService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class PayController extends BaseController
{
    public function againstDetail(Request $request): JsonResponse
    {
        $againstId = (int)$request->get('againstId');
        $shopId    = (int)$request->get('shopId');

        $this->validate($request, [
            'shopId' => 'required|integer|min:1',
            'againstId' => 'required|integer|min:1',
        ]);

        $signOrderModel = OpenShopSignOrderModel::getModelByShopId($shopId);

        $data = (new SignOrderService('', $signOrderModel, false, false))
            ->payAgainstDetail($againstId, $shopId);

        return $this->success($data);
    }
}
